<?php
include_once "../header1.php";
?>
<script type="text/javascript" src="popup-window.js"></script>
<?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   
   else
   {
   ?>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
	require_once 'csvread.php';
}
?>
 <?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?>
<div id="content">
	<div id="main">
	  <div id="bodyfield">
<br/><div id="lefttablereg">
<table width="948" height="402">
<tr>
  <td>&nbsp;</td>
  <td height="28" class="err"> 
  <?php
 include_once ("../uploerror.php");
 if(isset($_SESSION['errorinuploading']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errorinuploading'];
unset($_SESSION['errorinuploading']);
}
if(isset($_SESSION['errordata']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errordata'];
unset($_SESSION['errordata']);
}
if(isset($_SESSION['errorexi']))
{
echo $_SESSION['errorexi'];
unset($_SESSION['errorexi']);
}
if(isset($_SESSION['insertsucc']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['insertsucc'];
unset($_SESSION['insertsucc']);
}
?></td>
  <td></td>
  <td width="559" rowspan="3">
  </td>
</tr>
<tr>
  <td width="17">&nbsp;</td>
<td width="351" height="304">
 
  <h3>Teachers are an incredibly creative and resourceful bunch. They have to be,   considering the many personalities that they interact with each day and the many   mandates and requirements that define their professional responsibilities</h3></td>
<td width="10"></td>
</tr>
<td width="17" height="51">&nbsp;</td>
<td>&nbsp;
 </td>
<td width="10"></td>
</table>
  </div><div id="righttablereg">
  <?php  
  $t_nics="";
  $all_users=mysql_query("SELECT * FROM user");
  while($a_users=mysql_fetch_array($all_users))
  {
	$U_NIC_Number=$a_users['NIC_Number'];
	$Acc_Type=$a_users['Access_Type'];
	if($Acc_Type!="Administrator")
	{
	 $che_tea=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$U_NIC_Number'");
	 if(!$che_tea||mysql_num_rows($che_tea)==0)
	 {
		if(empty($t_nics))
		{
			$t_nics=$U_NIC_Number;
		}
		else
		{
			$t_nics=$t_nics.",".$U_NIC_Number;
		}
	 }
  }
  }
  if($t_nics!="")
  {
$t_nic_nos=explode(",",$t_nics);
if($_SESSION['Access_Type']=="Teacher in Charge")
{
$table="";
 for($i=0;$i<count($t_nic_nos);$i++)
  {
	   $nic=$t_nic_nos[$i];
	   $get_tea=mysql_query("SELECT * FROM user WHERE NIC_Number='$nic'");
	   if($get_tea_row=mysql_fetch_array($get_tea))
	   {
	   $Ac_Type=$get_tea_row['Access_Type'];
   if($Ac_Type=="Teacher")
   {
   $table="want";
   break;
   }
   }
   }
if($table=="want")
{
  echo '<table border="1" class="tablefontv">';
 echo '<tr bgcolor="#333333"><td><font color="white">First Name</font></td><td><font color="white">Last Name</font></td><td><font color="white">NIC Number</font></td><td><font color="white">E@Mail</font></td><td></td></tr>';
   for($i=0;$i<count($t_nic_nos);$i++)
  {
	  if(is_int($i/2))
    {
   $color="#999999";
    }
	else
	{
   $color="#CCCCCC";
    }
	   $nic=$t_nic_nos[$i];
	   $get_tea=mysql_query("SELECT * FROM user WHERE NIC_Number='$nic'");
	   if($get_tea_row=mysql_fetch_array($get_tea))
	   {
	   $Ac_Type=$get_tea_row['Access_Type'];
	   	   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   }
   if($Ac_Type!="Teacher in Charge"&&$Ac_Type!="Administrator")
   {
	   echo '<tr bgcolor="'.$color.'"><td>'.$get_tea_row['First_Name'].'</td><td>'.$get_tea_row['Last_Name'].'</td><td>'.$get_tea_row['NIC_Number'].'</td><td>'.$get_tea_row['E_Mail'].'</td><td><a href="regtea.php?School_Id='.$Own_School_Id.'&T_NIC_Number='.$get_tea_row['NIC_Number'].'&First_Name='.$get_tea_row['First_Name'].'&Last_Name='.$get_tea_row['Last_Name'].'">Edit</a></td></tr>';
	   }	       
	   }
  }
  echo '</table>';
  }
  else
  {
   ?>
  <img src="<?php echo "$basedir";?>/images/education-team-gis.jpg" width="509" height="330" style="border: solid 1px #D6E0E2; box-shadow: inset 0px 0px 0px 1px #fff; border: 0; -webkit-box-shadow:	inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -moz-box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px;"/>
  <?php
  }
  }
  else if($_SESSION['Access_Type']=="Administrator")
	   {
	     echo '<table border="1" class="tablefontv">';
  echo '<tr bgcolor="#333333"><td><font color="white">First Name</font></td><td><font color="white">Last Name</font></td><td><font color="white">NIC Number</font></td><td><font color="white">E@Mail</font></td><td></td></tr>';
  for($i=0;$i<count($t_nic_nos);$i++)
  {
	  if(is_int($i/2))
    {
   $color="#999999";
    }
	else
	{
   $color="#CCCCCC";
    }
	   $nic=$t_nic_nos[$i];
	   $get_tea=mysql_query("SELECT * FROM user WHERE NIC_Number='$nic'");
	   if($get_tea_row=mysql_fetch_array($get_tea))
	   {
	  echo '<tr bgcolor="'.$color.'"><td>'.$get_tea_row['First_Name'].'</td><td>'.$get_tea_row['Last_Name'].'</td><td>'.$get_tea_row['NIC_Number'].'</td><td>'.$get_tea_row['E_Mail'].'</td><td><a href="regtea.php?T_NIC_Number='.$get_tea_row['NIC_Number'].'&First_Name='.$get_tea_row['First_Name'].'&Last_Name='.$get_tea_row['Last_Name'].'">Edit</a></td></tr>';
	   }
	   }
	   echo '</table>';
	   }
	   }
  if($t_nics==""||$_SESSION['Access_Type']=="Teacher")
  {
  ?>
  <img src="<?php echo "$basedir";?>/images/education-team-gis.jpg" width="509" height="330" style="border: solid 1px #D6E0E2; box-shadow: inset 0px 0px 0px 1px #fff; border: 0; -webkit-box-shadow:	inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -moz-box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px;"/>
  <?php
  }
  ?>
  </div>
</div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">TEACHERS</h2>
            </div> 
                   <?php
 include_once ("uploform.php");
?> 
<?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
}
?>

</body>
</html>